package com.enba.mallapi.module.auth.controller.ex;

import com.enba.boot.core.enums.ICode;
import com.enba.boot.core.exception.BizException;

/** 用户相关异常码定义 */
public enum UserExCode implements ICode {
  USER_EXIST(10001, "用户已存在"),
  USER_NOT_EXIST(10002, "用户不存在"),
  USER_PSD_ERROR(10003, "密码错误"),
  USER_BE_DISABLED(10004, "用户禁用"),
  DEPT_NOT_EXIST(20001, "部门不存在"),
  DEPT_BE_DISABLED(20002, "部门被禁用"),
  DEPT_TYPE_ERROR(20003, "部门类型错误"),
  ROLE_NAME_EXIST(30001, "角色已存在"),
  USER_ROLE_EXIST(30002, "用户已绑定角色"),
  ROLE_NOT_EXIST(30003, "角色不存在"),
  ROLE_BIND_USER(30004, "角色已绑定用户"),
  ROLE_KEY_EXIST(30005, "角色权限字符已存在");

  private final int code;
  private final String msg;

  UserExCode(int code, String msg) {
    this.code = code;
    this.msg = msg;
  }

  @Override
  public Integer getCode() {
    return code;
  }

  @Override
  public String getMsg() {
    return msg;
  }

  /** 抛出异常 */
  public void throwEx() {
    BizException.throwEx(this);
  }
}
